<?php

/*
* t. бУ
*
* Test. ϸĹ
* @author allen
* @version $Id: $
* @package PhpDocumentor ĵǣ
*/

require_once './include/common.inc.php';

$pic1_ary = $pic2_ary = $pic3_ary = array();
$tr = '';

$sql_where = " where `hidden_flag` = 'n'";
if ($_GET['type'] == 'all') {
    $sql_where = "";
}


$sql = "SELECT `id`, `code`, `pic`, `small_pic` FROM `product` $sql_where ";
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {
    $id_ary[] = $rs['id'];
    if (!strstr(strtolower($rs['pic']), '.jpg') || !strstr(strtolower($rs['small_pic']), '.jpg') ) {
        $pic1_ary[$rs['id']] = $rs;
    }
    if (!file_exists("./zh/attachments/" . $rs['pic'])) {
        $pic2_ary[$rs['id']] = $rs;
    }
    if (!file_exists("./zh/attachments/" . $rs['small_pic'])) {
        $pic3_ary[$rs['id']] = $rs;
    }

}

/*
echo "<pre>";
print_r($pic1_ary);
print_r($pic2_ary);
print_r($pic3_ary);
exit;
*/

$flag1_info1 = 'excelȱͼƬϢ';
$flag2_info1 = '';
$flag3_info1 = '';

$flag1_info2 = '';
$flag2_info2 = 'ȱСͼ';
$flag3_info2 = 'ȱٴͼ';

if ($_GET['lang'] == 'zh_CN') {
    $flag1_info1 = 'excelȱͼƬϢ';
    $flag2_info1 = '';
    $flag3_info1 = '';
    
    $flag1_info2 = '';
    $flag2_info2 = 'ȱСͼ';
    $flag3_info2 = 'ȱٴͼ';
}



foreach ($id_ary as $v) {
    $flag1 = $flag2 = $flag3 = '&nbsp;';

    if (@array_key_exists($v, $pic1_ary) || @array_key_exists($v, $pic2_ary) || @array_key_exists($v, $pic3_ary)) {
        if (@array_key_exists($v, $pic1_ary)) {
            $flag1 = "<font color=red>$flag1_info1</font>";
            $info_ary = $pic1_ary[$v];

            $flag2 = "<font color=red>$flag2_info1</font>";
            $flag3 = "<font color=red>$flag3_info1</font>";

        } else {
            if (@array_key_exists($v, $pic2_ary)) {
                $flag2 = "";
                $info_ary = $pic2_ary[$v];
            } else {
                $flag2 = "<font color=red>$flag2_info2</font>";
                //$info_ary = $pic2_ary[$v];
            }

            if (@array_key_exists($v, $pic3_ary)) {
                $flag3 = "";
                $info_ary = $pic3_ary[$v];
            } else {
                $flag3 = "<font color=red>$flag3_info2</font>";
            }
        }

        if (!empty($flag2) || !empty($flag3)) {

            $tr .= "<tr align='center' bgcolor='#FFFFFF'>
            <td>" . $info_ary['code'] . "&nbsp;</td>
            <td>" . $info_ary['pic'] . "&nbsp;</td>
            <td>" . $info_ary['small_pic'] . "&nbsp;</td>
            <td>$flag1 &nbsp;</td>
            <td>$flag2 &nbsp;</td>
            <td>$flag3 &nbsp;</td>
            </tr>";
        }
        
        if (isset($_GET['debug']) && $_GET['debug'] == "allen") {
            echo $info_ary['code'] . "<br>";
        }
        
    }


}

if (isset($_GET['debug']) && $_GET['debug'] == "allen") {
    exit;
}

echo '<link rel="stylesheet" href="css/admin.css" type="text/css"><table border="0" cellspacing="1" cellpadding="5" bgcolor="#B68F2E"><tr align="center" bgcolor="#FFFFFF">
    <td><strong>Code</strong></td>
    <td><strong>Big pic</strong></td>
    <td><strong>Small pic</strong></td>
    <td><strong>Excel</strong></td>
    <td><strong>Big picture</strong></td>
    <td><strong>Small Picture</strong></td>
    </tr>' . $tr . '</table>';

?>